/*
 * @Author: yangni 920556271@qq.com
 * @Date: 2023-12-29 10:25:45
 * @LastEditors: yangni 920556271@qq.com
 * @LastEditTime: 2024-03-26 09:53:09
 * @FilePath: /yt-devops/lib/model/device_obj/service_config_model.dart
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import 'dart:convert';

import 'package:json_annotation/json_annotation.dart';
import 'package:yt_devops/model/device_obj/authority_config_model.dart';
import 'package:yt_devops/model/device_obj/prompt_rule_model.dart';
import 'package:yt_devops/model/device_obj/properties_model.dart';
import 'package:yt_devops/utils/enums.dart';

import 'product_config_model.dart';

part 'service_config_model.g.dart';

@JsonSerializable()
class ServiceConfigModel extends ProductConfigModel {
  List<PromptRuleModel>? promptRule;

  List<AuthorityModelConfig>? authority;

  DeviceModelShowType? showType;

  int? deviceId;

  List? buttons;

  /// 配置的要下发的参数key
  /// ``` dart
  ///   "extraKeys": [
  ///     "sn"
  ///   ]
  /// ```
  List? extraKeys;

  /// 配置的要下发的参数map
  /// ``` dart
  ///   "extraParams": {
  ///      "sn": ""
  ///   }
  Map? extraParams;

  String? tip;

  String? queryId;

  ServiceConfigModel(
      {required super.id,
      String? name,
      super.parentId,
      super.children,
      this.promptRule,
      this.authority,
      this.showType,
      this.deviceId,
      this.buttons,
      this.extraKeys,
      this.extraParams,
      this.tip,
      this.queryId})
      : super(type: DeviceConfigType.service, name: name);

  factory ServiceConfigModel.fromJson(Map<String, dynamic> json) =>
      _$ServiceConfigModelFromJson(json);

  copyWith(
          {String? idCope,
          String? nameCope,
          int? sortOrderCope,
          String? parentIdCope,
          List? childrenCope,
          List<PromptRuleModel>? promptRuleCope,
          List<AuthorityModelConfig>? authorityCope,
          DeviceModelShowType? showTypeCope,
          int? deviceIdCope,
          List? buttonsCope,
          List? extraKeysCope,
          Map? extraParamsCope,
          String? tipCope,
          String? queryIdCope}) =>
      ServiceConfigModel(
        id: idCope ?? id,
        name: nameCope ?? name,
        parentId: parentIdCope ?? parentId,
        children: childrenCope ?? children,
        promptRule: promptRuleCope ?? promptRule,
        authority: authorityCope ?? authority,
        showType: showTypeCope ?? showType,
        deviceId: deviceIdCope ?? deviceId,
        buttons: buttonsCope ?? buttons,
        extraKeys: extraKeysCope ?? extraKeys,
        extraParams: extraParamsCope ?? extraParams,
        tip: tipCope ?? tip,
        queryId: queryIdCope ?? queryId,
      );

  Map<String, dynamic> toJson() => _$ServiceConfigModelToJson(this);
}
